package com.hovhanna.monopoly.model;

import com.hovhanna.monopoly.common.Event;

public class Game extends Model<Game.GameEvent> {
    private static final int DEFAULT_WAIT_INTERVAL = 5000;
    
    private final Board board;
    private Dice dice;
    private Event rollDiceEvent = new Event();
    
    public Game() {
        board = new Board(this);
    }
    
    public void run() {
        
    }
    
    int rollDiceNeeded() {
        publish(GameEvent.ROLL_DICE_NEEDED);
        waitForRollDiceCommand();
        return dice.getValue();
    }
    
    private void waitForRollDiceCommand() {
        rollDiceEvent.waitForEvent(DEFAULT_WAIT_INTERVAL);
    }
    
    public void rollDiceCommanded() {
        dice.roll();
        rollDiceEvent.setEvent();
    }

    public static enum GameEvent {
        ROLL_DICE_NEEDED
    }
}
